import java.util.Arrays;

public class Test {
    //数组转换为字符串
    public static void main(String[] args){
        int[] arr = {0,1,2,3,4,5,6,7,8,9};
        System.out.println(Arrays.toString(arr));
    }

    //数组作为返回值
    public static int[] func(){
        int[] arr = {1,2,3,4};
        return arr;
    }
    public static void main2(String[] args){
        int[] arr = func();
        for(int i = 0; i < arr.length; i++){
            System.out.print(arr[i] + " ");
        }
        System.out.println();
    }
    public static void main1(String[] args) {
        //数组的定义与使用
        int[] array1 = {1,2,3,4,5};

        int[] array2 = new int[10];

        int[] array3 = new int[]{1,2,3,4,5,6};

        //打印数组名，结果为数组的地址
        System.out.println(array1);
        System.out.println(array2);
        System.out.println(array3);

        //数组分开定义
        int[] array4;
        array4 = new int[10];

        int[] array5;
        array5 = new int[]{1,2,3,4};

        //error
//        int[] array6;
//        array6 = {1,2,3,4,5};

        //数组的遍历
        //1、for循环遍历
        for(int i = 0; i < array5.length; i++){
            System.out.print(array5[i] + " ");
        }
        System.out.println();

        //for - each 遍历
        for(int x : array5){
            System.out.print(x + " ");
        }
        System.out.println();
    }
}
